# /usr/bin/python3
# coding=utf-8
# @Time:2025/8/3 16:22
# @Author: cc
import os


def get_project_path() :
    '''
    获取项目绝对路径
    '''
    project_name = 'check_price'
    file_path = os.path.dirname (__file__)
    return file_path[:file_path.find (project_name) + len (project_name)]


def sep(path, add_sep_before=False, add_sep_after=False) :
    '''
    获取相对路径
    :param path:
    :param add_sep_before:
    :param add_sep_after:
    :return:
    '''
    all_path = os.sep.join (path)
    if add_sep_before :
        all_path = os.sep + all_path
    if add_sep_after :
        all_path = all_path + os.sep
    return all_path


if __name__ == '__main__' :
    print (get_project_path ( ))
    sep (['config', 'enviroment.yaml'], add_sep_before=True, add_sep_after=True)

# 获取绝对路径
# 1.获取当前文件夹的路径
# 2.定义项目名称，通过find方法获取项目名称的下标索引
# 3.通过切片的方式获取目标文件的绝对路径
# 4.相对路径：通过sep()方法进行路径拼接，获取相对路径
